{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# TarDAL online tutorial | CVPR 2022\n",
    "\n",
    "This is the **official** TarDAL notebook, and is freely available for everyone.\n",
    "For more information please visit [GitHub Repository](https://github.com/JinyuanLiu-CV/TarDAL).\n",
    "Thank you!"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## Setup Environment\n",
    "\n",
    "Install requirements for TarDAL."
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "!nvidia-smi  # check GPU environment\n",
    "!git clone https://github.com/JinyuanLiu-CV/TarDAL.git  # clone repository from GitHub\n",
    "\n",
    "# use python 3.10\n",
    "!wget https://github.com/korakot/kora/releases/download/v0.10/py310.sh\n",
    "!bash ./py310.sh -b -f -p /usr/local\n",
    "!python -m ipykernel install --name \"py310\" --user\n",
    "\n",
    "%cd TarDAL\n",
    "%pip install -r requirements.txt  # install tardal requirements\n",
    "%pip install -r module/detect/requirements.txt # install yolov5 requirements"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "## Fuse or Eval\n",
    "\n",
    "### Load Image (List)\n",
    "\n",
    "infrared image(s):\n",
    "![infrared](assets/sample/s1/ir/M3FD_00471.png)\n",
    "\n",
    "visible image(s):\n",
    "![visible](assets/sample/s1/vi/M3FD_00471.png)\n",
    "\n",
    "### Init TarDAL Pipeline"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "from scripts import InferF\n",
    "from config import from_dict\n",
    "import yaml\n",
    "from pathlib import Path\n",
    "from IPython import display\n",
    "\n",
    "# init config\n",
    "config = yaml.safe_load(Path('config/official/colab.yaml').open('r'))\n",
    "config = from_dict(config)  # convert dict to object\n",
    "\n",
    "# init infer pipeline\n",
    "infer_p = InferF(config, save_dir='runs/sample/s1')\n",
    "\n",
    "# generate fusion sample\n",
    "infer_p.run()\n",
    "\n",
    "# display sample\n",
    "display.Image('runs/sample/s1/M3FD_00471.png')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "is_executing": true
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
